package SchedProc;


import SchedProc.Process.procState;
import SchedProc.procQueue;


public class Scheduler{
	procQueue roundRobin;
	procQueue prio[];
	Process currRUNNING;
	int schedType;

	
	    public Scheduler newScheduler(int max_processes, int sched_type){
		this.schedType = sched_type;
		this.roundRobin = procQueue.createQueue(max_processes);
		this.prio[2] = procQueue.createQueue(max_processes); 
		this.prio[1] = procQueue.createQueue(max_processes);
		this.prio[0] = procQueue.createQueue(max_processes); 
		return this;

	}

		void initializeScheduler(Scheduler s) {
	    	switch (s.schedType) { 
	    	case 0:           
	    		break;         
	    		case 1: 
	    			break;
	    			
	    		case 2:
	    			break;
	    	}
	    }
	    
	    Process switchProc(Scheduler s, int pc){
	    	
	    	Process nxt=null;
	    	switch( s.currRUNNING.state){
	    	
	    	case BLOCKED:
	    		s.currRUNNING.setnxtStep(pc);  
                nxt = procQueue.getFromReadyQueue(s);        
                if (nxt != null) {                      
        		s.currRUNNING = nxt;                         
        		s.currRUNNING.setState(procState.RUNNING);            
                }                 
                break;   
                
	    	case READY:
	    		s.currRUNNING.setnxtStep(pc);  
                nxt = procQueue.getFromReadyQueue(s);   
                procQueue.addToReadyQueue(s, s.currRUNNING);
                if (nxt != null) {                      
        		s.currRUNNING = nxt;                         
        		s.currRUNNING.setState(procState.RUNNING);           
                }                 
                break;   
                
	    	case RUNNING:
	    		s.currRUNNING.setnxtStep(pc);  
                s.currRUNNING.setState(procState.READY); 
                nxt = procQueue.getFromReadyQueue(s);   
                procQueue.addToReadyQueue(s, s.currRUNNING);
                if (nxt != null) {                      
        		s.currRUNNING = nxt;                         
        		s.currRUNNING.setState(procState.RUNNING);            
                }                 
                break;   
	    	
	    	}
	    	return nxt;
	    	
	    	
	    }



		



		
	    			
}